package org.example.service.impl;

import org.apache.shardingsphere.transaction.annotation.ShardingTransactionType;
import org.apache.shardingsphere.transaction.core.TransactionType;
import org.example.service.OrderService;
import org.example.mapper.OrderMapper;
import org.example.vo.OrderVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class OrderMybatisServiceImpl implements OrderService {

    @Autowired
    private OrderMapper orderMapper;

    @Override
    @Transactional
    @ShardingTransactionType(TransactionType.XA)
    public void insertDatas() {
        for (int i = 0; i < 10; i++) {
            OrderVO orderVO = new OrderVO();
            orderVO.setOrderId(i);
            orderVO.setUserId(i);
            orderVO.setAddressId(i);
            orderVO.setStatus("INIT");
            orderMapper.insert(orderVO);
        }

    }
}
